package com.lxw.mq.consumer;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lxw.mq.service.ICmsPageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ConsumerMq {

    @Autowired
    ICmsPageService cmsPageService;

    @RabbitListener(queues = "${fhs.mq.queue}")
    @RabbitHandler
    public void process(String msg){


        System.out.println(msg);

        JSONObject jsonObject = JSON.parseObject(msg);
        String pageId = jsonObject.getString("pageId");
        //获取到页面信息  下载到本地磁盘上
        cmsPageService.wirteFile(pageId);
    }
}
